import requests
from lxml import etree
url = 'https://www.qqtn.com/wm/meinvtp_1.html'
header = {
    'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/125.0.0.0 Safari/537.36 Edg/125.0.0.0'
}
res = requests.get(url, headers=header)
# data = res.content.decode('gbk') # 手动设置
res.encoding = res.apparent_encoding  # 自动获取解码格式
data = res.text
tree = etree.HTML(data)
url_list = tree.xpath('//ul[@class="g-gxlist-imgbox"]//img/@src')
url_title = tree.xpath('//ul[@class="g-gxlist-imgbox"]//a/@title')
for url, title in zip(url_list, url_title):
    print(f'下载{title}中-------')
    with open(f'./tnw/{title}.png', 'wb') as f:
        f.write(requests.get(url).content)
